@extends('layout.admin')

@section('title', '菜单管理')

@section('content')
    <style>
        .edit-content{
            background-color: #fff;
            max-width: 100%;
            flex: 0 0 100%;
            padding: 0 10px;
        }

        .edit-content .edit-form{
            padding: 18px;
        }

    </style>
    <div class="edit-content">
        @include('shared.adminAddHeader', [
        'addHeaderName' => '新增菜单',
        'svgIconName' => 'justify',
        'addBackUrl' => url('admin/role/menuIndex'),
        'addSaveUrl' => url('admin/role/menuSave'),
    ])

        <div class="edit-form">
            <form id="editForm">
                @if(isset($editObject->id))
                    <input type="hidden" name="id" value="{{$editObject->id}}">
                @endif
                <div class="form-group row">
                    <label for="name" class="col-sm-3 col-form-label"><span class="text-danger">*</span>菜单名称：</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="name" name="name" required
                               @if(isset($editObject->name)) value="{{$editObject->name}}" @else value="" @endif placeholder="请输入菜单名称">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="rowNum" class="col-sm-3 col-form-label"><span class="text-danger">*</span>菜单排序：</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="rowNum" name="row_num" required
                               @if(isset($editObject->row_num)) value="{{$editObject->row_num}}" @else value="" @endif placeholder="请输入菜单排序">
                        <small>同级排序，菜单序号在0到60000之间整数</small>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="fatherId" class="col-sm-3 col-form-label"><span class="text-danger">*</span>上级目录：</label>
                    <div class="col-sm-9">
                        <select class="form-control" name="father_id" id="fatherId" @if(isset($editObject->level) && in_array($editObject->level, [1,2])) disabled @endif>
                            <option value="0" selected>根目录</option>
                            @if(isset($fatherArr) && is_array($fatherArr))
                            @foreach($fatherArr as $fKey=>$fVal)
                                    <option value="{{$fVal['id']}}" @if(isset($editObject->father_id) && ($fVal['id'] == $editObject->father_id)) selected @endif>
                                        {{$fVal['name']}}
                                    </option>
                                @if(!empty($fVal['children']) && is_array($fVal['children']))
                                    @foreach($fVal['children'] as $cKey=>$cVal)
                                            <option value="{{$cVal['id']}}" @if(isset($editObject->father_id) && ($cVal['id'] == $editObject->father_id)) selected @endif >
                                            ----{{$cVal['name']}}
                                            </option>
                                    @endforeach
                                @endif
                            @endforeach
                            @endif
                        </select>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="url" class="col-sm-3 col-form-label">路由别名：</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="url" name="url" required
                               @if(isset($editObject->url['value'])) value="{{$editObject->url['value']}}" @else value="" @endif placeholder="请输入菜单首页的url">
                        <small>如菜单首页：http://local.laravel8.com/admin/role/menuIndex，请输入：admin/role/menuIndex</small>
                    </div>

                </div>
                <div class="form-group row">
                    <label for="icon" class="col-sm-3 col-form-label">菜单icon：</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" id="icon" name="icon" required
                               @if(isset($editObject->icon)) value="{{$editObject->icon}}" @else value="" @endif placeholder="请输入菜单的icon">
                        <small>请输入Bootstrap图标库名称如：alarm-fill</small>
                    </div>
                </div>

                <div class="form-group row">
                    <label class="col-sm-3 col-form-label"><span class="text-danger">*</span>菜单是否显示：</label>
                    <div class="col-sm-9">
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="is_show" id="menuIsShowNot" value="0" checked>
                            <label class="form-check-label" for="menuIsShowNot">否</label>
                        </div>
                        <div class="form-check form-check-inline">
                            <input class="form-check-input" type="radio" name="is_show" id="menuIsShowYes" value="1"
                            @if(isset($editObject->is_show) && 1 == $editObject->is_show['value']) checked @endif >
                            <label class="form-check-label" for="menuIsShowYes">是</label>
                        </div>
                    </div>
                </div>

            </form>
        </div>
    </div>
@endsection
